package fudan.se.project.repository.projection;

import fudan.se.project.domain.conference.post.Post;

import java.util.ArrayList;
import java.util.Collection;
import java.util.List;

public class PostProjection {

    private final Post post;

    private PostProjection(Post post) {
        this.post = post;
    }

    public long getId() {
        return post.getId();
    }

    public String getTitle() {
        return post.getTitle();
    }

    public List<ReplyProjection> getReplies() {
        return ReplyProjection.project(post.getReplies());
    }


    public static PostProjection project(Post post) {
        return new PostProjection(post);
    }

    public static List<PostProjection> project(Collection<Post> posts) {
        ArrayList<PostProjection> arrayList = new ArrayList<>(posts.size());
        for (Post value : posts) {
            arrayList.add(project(value));
        }
        return arrayList;
    }
}
